package com.web.employees;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.domain.Employees;
import com.service.EmployeesService;
import com.util.AuthenticateHttpServlet;
import com.util.PageMaker;

/**
 * Servlet implementation class EmployeeList
 */
@WebServlet("/Employee/List")
public class EmployeeList extends AuthenticateHttpServlet {
	private static final long serialVersionUID = 1L;

	protected void post(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		EmployeesService dao = new EmployeesService();
		List<Employees> list = dao.getAllEmployees();
		/*int currentPage = 0;
		if (request.getParameter("page") != null) {
			currentPage = Integer.parseInt(request.getParameter("page"));

			if (request.getParameter("action").equals("next")) {
				currentPage++;
			}
			if (request.getParameter("action").equals("previous")) {
				currentPage--;
			}
		}
		PageMaker<Employees> maker = new PageMaker<Employees>(5);
		List<Employees> output = maker.getCurrentPageList(list, currentPage);
		currentPage = maker.getCurrentPage();
		request.setAttribute("page", currentPage);
		request.setAttribute("employees", output);*/
		request.setAttribute("em", list);
		request.getRequestDispatcher("/WEB-INF/jsp/employeeList.jsp").forward(
				request, response);
	}

}
